<?php

class m111026_023710_employee_full extends CDbMigration {
	public function safeUp() {
		$this->addColumn('erp_employee', 'documentNumber', 'string');
		$this->addColumn('erp_employee', 'gender', 'int');
		$this->addColumn('erp_employee', 'ethnicGroup', 'string');
		$this->addColumn('erp_employee', 'homeTown', 'string');
		$this->addColumn('erp_employee', 'education', 'string');
		$this->addColumn('erp_employee', 'profession', 'string');
		$this->addColumn('erp_employee', 'dateOfBirth', 'date');
		$this->addColumn('erp_employee', 'healthCondition', 'string');
		$this->addColumn('erp_employee', 'hireDate', 'date');
		$this->addColumn('erp_employee', 'maritalStatus', 'string');
		$this->addColumn('erp_employee', 'currentRank', 'string');
		$this->addColumn('erp_employee', 'politicalStatus', 'string');
		$this->addColumn('erp_employee', 'contactMobile', 'string');
		$this->addColumn('erp_employee', 'contactPhone', 'string');
		$this->addColumn('erp_employee', 'originalHomeAddress', 'string');
		$this->addColumn('erp_employee', 'currentAddress', 'string');
		$this->addColumn('erp_employee', 'emergencyContactName', 'string');
		$this->addColumn('erp_employee', 'emergencyContactPhone', 'string');
		$this->addColumn('erp_employee', 'identityCardNumber', 'string');
		$this->addColumn('erp_employee', 'graduationSchool', 'string');
		$this->addColumn('erp_employee', 'certificates', 'string');
		$this->addColumn('erp_employee', 'personalHabits', 'string');
		$this->addColumn('erp_employee', 'personalSocialPension', 'boolean');
		$this->addColumn('erp_employee', 'personalSocialInjury', 'boolean');
		$this->addColumn('erp_employee', 'personalSocialUemployed', 'boolean');
		$this->addColumn('erp_employee', 'personalSocialIllness', 'boolean');
		$this->addColumn('erp_employee', 'personalSocialInsurance', 'boolean');
		$this->addColumn('erp_employee', 'familyMembers', 'text');
		$this->addColumn('erp_employee', 'educationDetails', 'text');
		$this->addColumn('erp_employee', 'workExperience', 'text');
		$this->addColumn('erp_employee', 'outstandingAchievement', 'text');
		$this->addColumn('erp_employee', 'note', 'text');
		$this->addColumn('erp_employee', 'trialDate', 'date');
		$this->addColumn('erp_employee', 'trialSalary', 'decimal(8,2)');
		$this->addColumn('erp_employee', 'employedDate', 'date');
		$this->addColumn('erp_employee', 'unemployedDate', 'date');
		$this->addColumn('erp_employee', 'signedCommitment', 'boolean');
		$this->addColumn('erp_employee', 'signedSecrecyAgreement', 'boolean');
		$this->addColumn('erp_employee', 'signedTrailContract', 'boolean');
		$this->addColumn('erp_employee', 'signedEmploymentContract', 'boolean');
		$this->addColumn('erp_employee', 'signedGuaranteeStatement', 'boolean');
		$this->addColumn('erp_employee', 'signedJobStatement', 'boolean');
		$this->addColumn('erp_employee', 'companyNote', 'text');
		$this->addColumn('erp_employee', 'personalPhotoFile', 'string');
		$this->addColumn('erp_employee', 'personalPhotoThumb', 'string');

		$this->addColumn('erp_employee', 'createTime', 'datetime');
		$this->addColumn('erp_employee', 'createUserId', 'int');
		$this->addColumn('erp_employee', 'updateTime', 'datetime');
		$this->addColumn('erp_employee', 'updateUserId', 'int');

		$this->createIndex("employee_create_user_id", 'erp_employee', 'createUserId');
		$this
			->addForeignKey('fk_employee_create_user_id', 'erp_employee', 'createUserId',
				'erp_user', 'id', 'SET NULL', 'CASCADE');
		$this->createIndex("employee_update_user_id", 'erp_employee', 'updateUserId');
		$this
			->addForeignKey('fk_employee_update_user_id', 'erp_employee', 'updateUserId',
				'erp_user', 'id', 'SET NULL', 'CASCADE');
	}

	public function safeDown() {
		$this->dropColumn('erp_employee', 'documentNumber');
		$this->dropColumn('erp_employee', 'gender');
		$this->dropColumn('erp_employee', 'ethnicGroup');
		$this->dropColumn('erp_employee', 'homeTown');
		$this->dropColumn('erp_employee', 'education');
		$this->dropColumn('erp_employee', 'profession');
		$this->dropColumn('erp_employee', 'dateOfBirth');
		$this->dropColumn('erp_employee', 'healthCondition');
		$this->dropColumn('erp_employee', 'hireDate');
		$this->dropColumn('erp_employee', 'maritalStatus');
		$this->dropColumn('erp_employee', 'currentRank');
		$this->dropColumn('erp_employee', 'politicalStatus');
		$this->dropColumn('erp_employee', 'contactMobile');
		$this->dropColumn('erp_employee', 'contactPhone');
		$this->dropColumn('erp_employee', 'originalHomeAddress');
		$this->dropColumn('erp_employee', 'currentAddress');
		$this->dropColumn('erp_employee', 'emergencyContactName');
		$this->dropColumn('erp_employee', 'emergencyContactPhone');
		$this->dropColumn('erp_employee', 'identityCardNumber');
		$this->dropColumn('erp_employee', 'graduationSchool');
		$this->dropColumn('erp_employee', 'certificates');
		$this->dropColumn('erp_employee', 'personalHabits');
		$this->dropColumn('erp_employee', 'personalSocialPension');
		$this->dropColumn('erp_employee', 'personalSocialInjury');
		$this->dropColumn('erp_employee', 'personalSocialUemployed');
		$this->dropColumn('erp_employee', 'personalSocialIllness');
		$this->dropColumn('erp_employee', 'personalSocialInsurance');
		$this->dropColumn('erp_employee', 'familyMembers');
		$this->dropColumn('erp_employee', 'educationDetails');
		$this->dropColumn('erp_employee', 'workExperience');
		$this->dropColumn('erp_employee', 'outstandingAchievement');
		$this->dropColumn('erp_employee', 'note');
		$this->dropColumn('erp_employee', 'trialDate');
		$this->dropColumn('erp_employee', 'trialSalary');
		$this->dropColumn('erp_employee', 'employedDate');
		$this->dropColumn('erp_employee', 'unemployedDate');
		$this->dropColumn('erp_employee', 'signedCommitment');
		$this->dropColumn('erp_employee', 'signedSecrecyAgreement');
		$this->dropColumn('erp_employee', 'signedTrailContract');
		$this->dropColumn('erp_employee', 'signedEmploymentContract');
		$this->dropColumn('erp_employee', 'signedGuaranteeStatement');
		$this->dropColumn('erp_employee', 'signedJobStatement');
		$this->dropColumn('erp_employee', 'companyNote');
		$this->dropColumn('erp_employee', 'personalPhotoFile');
		$this->dropColumn('erp_employee', 'personalPhotoThumb');

		$this->dropForeignKey('fk_employee_create_user_id', 'erp_employee');
		$this->dropIndex("employee_create_user_id", 'erp_employee');
		$this->dropForeignKey('fk_employee_update_user_id', 'erp_employee');
		$this->dropIndex("employee_update_user_id", 'erp_employee');

		$this->dropColumn('erp_employee', 'createTime');
		$this->dropColumn('erp_employee', 'createUserId');
		$this->dropColumn('erp_employee', 'updateTime');
		$this->dropColumn('erp_employee', 'updateUserId');

	}
}
